from http.server import HTTPServer, SimpleHTTPRequestHandler

'''
python 实现一个简单的http服务器
可以在浏览器中访问 http://localhost:8000 查看效果
'''

class RequestHandler(SimpleHTTPRequestHandler):

    def do_GET(self):
        self.send_response(200)
        self.end_headers()
        self.wfile.write('<h1>hello, world</h1>'.encode())


server = HTTPServer(('', 8000), RequestHandler)
server.serve_forever()